<?php

/**
 * @Author: Wang chunsheng  email:2192138785@qq.com
 * @Date:   2022-04-22 14:40:19
 * @Last Modified by:   Wang chunsheng  email:2192138785@qq.com
 * @Last Modified time: 2023-06-08 10:11:14
 */

namespace Common\traits;

use Common\Models\sys\CurlClient;
use EasySwoole\ORM\DbManager;
use Helpers\DebugHelper;

trait CallBackTrait
{
    protected static function onAfterUpdate($model, $res)
    {
        // DebugHelper::consoleWrite('条件', $model::$where);
        // if ($model::$where) {
        //     $deviceInfo = $model::create()->where($model::$where)->get();
        //     DebugHelper::consoleWrite('设备数据', $deviceInfo);
        //     if ($deviceInfo) {
        //         $apiUrl = SysDeviceCallback::create()->where(['project_id' => $deviceInfo['project_id']])->value('url');
        //         if ($apiUrl) {
        //             // 触发回调
        //             $curlClient = new CurlClient($apiUrl);
        //             $device_status = $deviceInfo->toArray();
        //             unset($device_status['id']);
        //             $Res = $curlClient->PostJson($apiUrl, [
        //                 'device_status' => $device_status
        //             ]);

        //             DebugHelper::consoleWrite('回调结果', $Res);
        //         }
        //     }
        // }
    }
}
